const { Sequelize, DataTypes } = require('sequelize')
const config = require('../config/config.js')
const sequelize = new Sequelize(config)

let articleModel = sequelize.define(
  'article',
  {
	  // 在这里定义模型属性
	  title: {
		  type: DataTypes.STRING,
		  comment: '标题'
	  },
	  author: {
		  type: DataTypes.STRING,
		  comment: '作者'
	  },
	  image: {
		  type: DataTypes.STRING,
		  comment: '缩略图'
	  },
	  cid: {
		  type: DataTypes.INTEGER,
		  comment: '栏目'
	  },
	  cname: {
		  type: DataTypes.STRING,
		  comment: '栏目名称'
	  },
	  intro: {
		  type: DataTypes.STRING,
		  comment: '简介'
	  },
	  content: {
		  type: DataTypes.TEXT,
		  comment: '内容'
	  },
	  keyword: {
		  type: DataTypes.STRING,
		  comment: '关键词'
	  },
	  views: {
		  type: DataTypes.INTEGER,
		  comment: '浏览量',
		  defaultValue: 0
	  },
	  created_time: {
		  type: Sequelize.INTEGER,
		  comment: '创建时间',
		  defaultValue: Date.parse(new Date()) / 1000
	  },
	  updated_time: {
		  type: Sequelize.INTEGER,
		  comment: '更新时间',
		  defaultValue: Date.parse(new Date()) / 1000
	  }
  },
  {
	  // 这是其他模型参数
	  timestamps: false,
	  tableName: 'article'
  }
)

module.exports = articleModel
